package com.zklh.leetcode.interviewTop150;

import java.util.Arrays;

/**
 * H指数
 *
 * @Author tongnan
 * @Date 2024/6/3
 * @Version 1.0
 */
public class Solution274 {
    public int hIndex(int[] citations) {
        int maxH = 0;
        Arrays.sort(citations);

        for (int i = 1; i <= citations.length; i++) {
            if (citations[citations.length-i] >= i) {
                maxH = i;
            }
        }
        return maxH;
    }

    public static void main(String[] args) {
        Solution274 solution274= new Solution274();
        int[] citations = {3,0,6,1,5};
        System.out.println(solution274.hIndex(citations));
    }
}